package com.smh.aiagent.demo.invoke;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author shiminghui
 * @date 2025/5/30 16:51
 * @description: TODO
 */
@Component
public class ChatClientInvoke implements CommandLineRunner {

    private final ChatClient chatClient;

    public ChatClientInvoke(@Qualifier(value = "dashscopeChatModel") ChatModel chatModel) { //@Qualifier(value = "dashscopeChatModel")无效
        this.chatClient = ChatClient.builder(chatModel).build();
    }

    @Override
    public void run(String... args) throws Exception {
//        ChatClient.CallResponseSpec responseSpec = chatClient
//                .prompts(new Prompt(new SystemMessage("你只会说'好'"), new UserMessage("你好")))
//                .call();
//        responseSpec.chatResponse().getResults().forEach(e->{
//            System.out.println(e.getOutput().getText());
//        });

    }
}
